package com.sleet.yuemiao.comment;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @program: yuemiao
 * @ClassName ThreadPool
 * @description:
 * @author: Liyongxing
 * @create: 2021-12-28 19:17
 **/
@Configuration
public class ThreadPool {
    //线程池核心线程数
    private int corePoolSize = 4;
    //线程池最大数
    private int maximumPoolSize = 4;
    //空闲线程存活时间
    private long keepAliveTime =120;
    @Bean(name = "creditAccountPoolExecutor")
    public ExecutorService executorService(){
        return new ThreadPoolExecutor(corePoolSize, maximumPoolSize,
                keepAliveTime, TimeUnit.SECONDS,
                new SynchronousQueue<Runnable>());
    }
}
